package offer.singleLinkedList;

/**
 * Description：算法使用，简单单链表，只有节点。无长度
 * Author: zhangc
 * Date：2017/7/18 15:22
 */
public class LinkedList<T> {

    public T value;

    public LinkedList next;

    public void setNext(LinkedList<T> next) {
        this.next = next;
    }

    public LinkedList() {
    }

    public LinkedList(T val) {
        this.value = val;
    }

    public void append(T value) {
        if (this.value == null) {
            this.value = value;
            return;
        }
        LinkedList head = this;
        while (head.next != null)
            head = head.next;
        head.next = new LinkedList(value);
    }

    public T getValue() {
        return value;
    }

    public LinkedList<T> getNext() {
        return next;
    }
}
